﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SmartMathLibrary.Statistics.RandomNumberGenerator
{
    /// <summary>
    /// This class represents an abstract layer for all random generators.
    /// </summary>
    [Serializable]
    public abstract class AbstractRandomGenerator
    {
        /// <summary>
        /// This field holds the seed value.
        /// </summary>
        private readonly uint seed;

        /// <summary>
        /// Initializes a new instance of the <see cref="AbstractRandomGenerator"/> class.
        /// </summary>
        /// <param name="seed">A number used to calculate a starting value for the pseudo-random number sequence. 
        /// If a negative number is specified, the absolute value of the number is used.</param>
        protected AbstractRandomGenerator(uint seed)
        {
            this.seed = seed;
        }

        /// <summary>
        /// Gets the seed value.
        /// </summary>
        /// <value>The seed value.</value>
        public uint Seed
        {
            get { return this.seed; }
        }

        /// <summary>
        /// Returns a nonnegative random number.
        /// </summary>
        /// <returns>A 32-bit signed integer greater than or equal to zero and less than maximum integer value.</returns>
        public abstract int Next();

        /// <summary>
        /// Nexts the specified max value.
        /// </summary>
        /// <param name="maxValue">Returns a nonnegative random number less than the specified maximum.</param>
        /// <returns>A 32-bit signed integer greater than or equal to zero and less than maximum integer value.</returns>
        public abstract int Next(int maxValue);

        /// <summary>
        /// Returns a random number within a specified range.
        /// </summary>
        /// <param name="minValue">The inclusive lower bound of the random number returned.</param>
        /// <param name="maxValue">The exclusive upper bound of the random number returned. maxValue must be 
        /// greater than or equal to minValue.</param>
        /// <returns>A 32-bit signed integer greater than or equal to zero and less than maximum integer value.</returns>
        public abstract int Next(int minValue, int maxValue);

        /// <summary>
        /// Returns a random number between 0.0 and 1.0.
        /// </summary>
        /// <returns>A double-precision floating point number greater than or equal to 0.0, and less 
        /// than 1.0.</returns>
        public abstract double NextDouble();
    }
}